package de.clapp.client.menue.filter;

import java.awt.Color;
import java.awt.GridLayout;

import javax.swing.JTextField;
import javax.swing.table.TableRowSorter;

import de.clapp.client.menue.MenueTableModel;
import de.clapp.client.musicbox.filter.RemoveInitialTextFocusListener;
import de.clapp.panels.MyPanel;

public class MenueCardFilterPanel extends MyPanel
{
    
    /**
     * 
     */
    private static final long serialVersionUID = -8971194808542466121L;

    public MenueCardFilterPanel(MenueTableModel tableModel, TableRowSorter<MenueTableModel> sorter)
    {
        this.setOpaque(true);

        this.setLayout(new GridLayout(1, 0, 3, 3));
        
        this.setBackground(new Color(240, 245, 250));

        MenueCardFilterModel filterModel = new MenueCardFilterModel(3, sorter);
        
        JTextField tf = new JTextField("Artikel");
        tf.getDocument().addDocumentListener(new MenueCardFilterDocumentListener(tf, 0, filterModel));
        tf.addFocusListener(new RemoveInitialTextFocusListener(tf, "Artikel"));
        this.add(tf);
        
        tf = new JTextField("Preis");
        tf.getDocument().addDocumentListener(new MenueCardFilterDocumentListener(tf, 1, filterModel));
        tf.addFocusListener(new RemoveInitialTextFocusListener(tf, "Einzelpreis"));
        this.add(tf);
        
        tf = new JTextField("Kategorie");
        tf.getDocument().addDocumentListener(new MenueCardFilterDocumentListener(tf, 2, filterModel));
        tf.addFocusListener(new RemoveInitialTextFocusListener(tf, "Kategorie"));
        this.add(tf);
    }
}
